package com.tchhy.provider.service.impl

import com.tchhy.provider.data.common.BaseResp
import com.tchhy.provider.data.partner.response.MedicineDetailResp
import com.tchhy.provider.data.partner.MedicineKitApplyInfo
import com.tchhy.provider.data.partner.MedicineKitDetailRequestModel
import com.tchhy.provider.data.partner.MedicineKitSalesInfo
import com.tchhy.provider.data.partner.MedicineRequestModel
import com.tchhy.provider.data.partner.request.ApplyDrugExaminationListResponseInfo
import com.tchhy.provider.data.partner.request.CommitApplyDataReq
import com.tchhy.provider.data.partner.request.PaymentCodeModel
import com.tchhy.provider.data.partner.request.SavePaymentInfoReq
import com.tchhy.provider.data.partner.response.*
import com.tchhy.provider.repository.CommonRepository
import com.tchhy.provider.repository.partner.WorkRepository
import com.tchhy.provider.service.MedicineService
import io.reactivex.Observable

/**
 * @author: admin
 * @date: 2019/8/20
 * @des:
 *
 **/
class MedicineServiceIml : MedicineService {

    override fun getExamition(): Observable<BaseResp<DataListRes<ApplyDrugExaminationListResponseInfo>>> {
        return commonRepository.applyExamationDrugList()
    }

    override fun getMedicineOrderDetail(orderNumber: String): Observable<BaseResp<ApplyMedicineRes>> {
        return workRepository.getMedicineKitDetail(orderNumber)
    }

    private val commonRepository by lazy { CommonRepository() }
    private val workRepository by lazy { WorkRepository() }

    /**
     * @description
     * @param
     * @return
     * @author admin
     * @time 2019/8/20
     */
    override fun medicineAcount(accout: String): Observable<BaseResp<MedicineKitApplyInfo>> {
        return commonRepository.getMedicineKitApplyAccount(MedicineRequestModel(medicineChest = accout))
    }


    override fun getMedicineKitSalesDetails(): Observable<BaseResp<MedicineKitSalesInfo>> {
        return workRepository.getMedicineKitSalesDetail()
    }

    override fun getServiceOrderList(pageNum: Int, pageSize: Int): Observable<BaseResp<ServiceOrdersRes>> {
        return workRepository.getServiceOrderList(pageNum, pageSize)
    }

    /**
     * @description 获取支付码
     * @param
     * @return
     * @author admin
     * @time 2019/8/22
     */
    override fun getPaymentCode(paymentAmount: Int, paymentChannel: Int): Observable<BaseResp<PaymentCodeInfo>> {
        return workRepository.getPaymentCode(paymentCodeModel = PaymentCodeModel(paymentAmount, paymentChannel))
    }

    /**
     * @description 服务订单
     * @param
     * @return
     * @author admin
     * @time 2019/8/22
     */
    override fun getOrderDetail(orderId: String): Observable<BaseResp<ServiceOrderDetailRes>> {
        return workRepository.getOrderDetail(orderId)
    }

    override fun getPaymentResult(paymentId: String): Observable<BaseResp<PaymentResultRes>> {
        return workRepository.getPaymentResult(paymentId)
    }


    override fun savePaymentResult(saveInfo: SavePaymentInfoReq): Observable<BaseResp<SavePaymentRes>> {
        return workRepository.savePaymentResult(saveInfo)
    }


    override fun getApplyMedicineInfo(): Observable<BaseResp<ApplyReciveAddress>> {
        return workRepository.getApplyMedicineInfo()
    }

    override fun commitApply(commitApplyRes: CommitApplyDataReq): Observable<BaseResp<CommitApplyRes>> {
        return workRepository.commitApply(commitApplyRes)
    }

    override fun getMedicineKitDetail(kitId: String): Observable<BaseResp<MedicineDetailResp>> {
        return workRepository.getMedicineKitDetail(MedicineKitDetailRequestModel(kitId = kitId))
    }





}